﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using NumericalData;
using NumericalData.DifferentialEquations.Methods;
using NumericalData.Interpolation.Data;
using NumericalData.Interpolation.Data.Methods;
using NumericalData.DifferentialEquations.Data;
using GraphEntities;

namespace TestNMConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            var funcs =
                new List<string>
                    {
                        "2*t*y1*y4",
                        "10*t*(y1^5)*y4",
                        "2*t*y4",
                        "-2*t*(y3 - 1)"
                    };
            var h = 0.01;
            var startValues =
                new List<double>
                    {
                        1,
                        1,
                        1,
                        1
                    };
            double from = 0;
            double to = 1;

            CauchyProblemContainer cont = new CauchyProblemContainer(funcs, startValues, from, to);

            var meth = new SevenOrderFelbergMethod(cont);

            var ans = meth.Solve(h);

            var t5 = ans.OdeValues[5].T;
            var gotY1 = ans.OdeValues[5].Y[1];
            var realY1 =
                RealY1(t5);

            Console.WriteLine(String.Format("got {0}, real {1}",gotY1,realY1));
            Console.ReadLine();
        }

        private static double RealY1(double t)
        {
            return Math.Exp(Math.Sin(Math.Pow(t, 2)));
        }
    }
}
